package io.itit.ecp.admin.provide.action.resp.miniprogram;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;


@Data
@ApiModel(value = "预测精度返回体")
@Accessors(chain = true)
public class AiPredictionAccuracyResp implements Serializable {

    @ApiModelProperty("名称(用电量、发电量)")
    private String name;

    @ApiModelProperty("统计值")
    private BigDecimal value;

    @ApiModelProperty("同比值")
    private BigDecimal preValue;

    @ApiModelProperty("环比值")
    private BigDecimal mValue;

    @ApiModelProperty("环比率")
    private BigDecimal mRate;

    @ApiModelProperty("同比是否上升")
    public Boolean getIsUp() {
        return value.compareTo(preValue) > 0;
    }

    @ApiModelProperty("同比率(百分比)")
    public BigDecimal getPreRate() {
        BigDecimal subValue = value.subtract(preValue);
        if (preValue.doubleValue() == 0.0D) {
            return new BigDecimal("100");
        }
        return subValue.divide(preValue, 2, RoundingMode.HALF_DOWN).multiply(new BigDecimal(("100"))).setScale(2, RoundingMode.HALF_DOWN);
    }

    @ApiModelProperty("环比是否上升")
    public Boolean getIsMUp() {
        return value.compareTo(mValue) > 0;
    }


}
